package itsm.isperp.module.service.app;

import itsm.isperp.framework.service.BaseService;
import itsm.isperp.framework.web.request.JqGridFilterRuleOp;
import itsm.isperp.framework.web.request.JqGridRequest;
import itsm.isperp.module.entity.app.AppCalendarWorkdate;
import itsm.isperp.module.repository.app.AppCalendarWorkdateMapper;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.stereotype.Service;

/**
 * 工作日服务
 * 
 * @author lizx
 * @date 2013-5-12
 * @version V1.0
 */
@Service
public class AppCalendarWorkdateService extends
		BaseService<AppCalendarWorkdate> {

	@Autowired
	protected AppCalendarWorkdateMapper appCalendarWorkdateMapper;

	@Override
	public AppCalendarWorkdateMapper getRepository() {
		return this.appCalendarWorkdateMapper;
	}

	public AppCalendarWorkdate findOneByWorkdateAndConfig(Date date,
			String configId) {
		return this.appCalendarWorkdateMapper.findOneByWorkdateAndConfig(date,
				configId);
	}

	/**
	 * 
	 * @param configId
	 * @return
	 */
	public List<AppCalendarWorkdate> findByConfigId(String configId) {

		JqGridRequest req = new JqGridRequest();
		req.addFilterRule("app_calendar_config_id", JqGridFilterRuleOp.eq,
				configId);
		req.isPageable(false);
		req.setSort("calendar_date", Direction.ASC);

		return this.findAll(req);
	}

}
